<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Database Reliability Benchmark</title>
    <link href="{{ url_for('static', path='/styles.css') }}" rel="stylesheet">

</head>
<body>
{% set timer_seq = namespace(t=0) %}
<script src="{{ url_for('static', path='/jquery-3.7.1.min.js') }}"></script>

<script type="text/javascript">
    setInterval(function () {
        $("#trxStats").load(location.href + " #trxStatsLine>*",""); //注意后面DIV的ID前面的空格，很重要！没有空格的话，会出错（也可以使用类名）
    }, 2000);          //2秒自动刷新
</script>

<div id="trxStats">
    <div id="trxStatsLine">
        <table>
            <thead>
            <tr>
                <th>用户</th>
                {% for line in txn_stats %}
                    {% set timer_seq.t = timer_seq.t + 1%}
                    <th>{{ line.ts }}</th>
                {% endfor %}
            </tr>
            </thead>
            <tbody>
            {% for u in ['user1', 'user2', 'user3', 'user4'] %}
            <tr>
                <td>{{ u }}</td>
                <!-- Expected work -->
                {% for x in txn_stats %}
                    <td>{{ x.succ_req + x.err_req + x.abort_req + x.retry_req + x.unknown_req }}</td>
                {% endfor %}
            </tr>
            <tr>
                <td></td>
                <!-- Actual work -->
                {% for line in txn_stats %}
                    {% if line.succ_req > 0 %}
                        <td>{{ line.succ_req }}</td>
                    {% else %}
                        <td></td>
                    {% endif %}
                {% endfor %}
            </tr>
            {% endfor %}

            <tr>
                <td>故障</td>
                {% for line in txn_stats %}
                    {% if line.fault_id > 0 %}
                        <td>{{ line.fault_id }}</td>
                    {% else %}
                        <td></td>
                    {% endif %}
                {% endfor %}
            </tr>
            </tbody>
        </table>
        <p>累积 work: {{ pre_succ }}, err work: {{pre_err}}, abort work: {{pre_abort}}, retry work: {{pre_retry}}, unknown work: {{pre_unknown}}
    </div>
</div>

</body>
</html>